<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
		<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
		<title>互评的开始互评view</title>
		<link rel="stylesheet" type="text/css" href="../../css/api.css"/>
		<link rel="stylesheet" href="../../css/weui.min.css" />
		<link rel="stylesheet" href="../../css/mui.min.css" />
		<link rel="stylesheet" href="../../css/base.css"/>
		<style type="text/css" media="screen">
			html, body {
				background-color: #f3f5f7;
			}
			.top-hand-div-style {
				text-align: center;
				margin-top: 80px;
				background-color: #FFFFFF;
				border: 2px solid #FFFFFF;
				border-radius: 6px;
				margin-right: 10px;
				margin-left: 10px;
				padding-top: 20px;
				padding-bottom: 20px;
				position: absolute;
				left: 0;
				right: 0;
				top: 0;
				bottom: 50px;
			}
			.top-hand-img-style {
				width: 120px;
				height: 120px;
				border-radius: 60px;
			}
			.top-hand-span-style {
				display: block;
				/*padding-bottom: 20px;*/
			}
			.bottom-btn-div {
				position: fixed;
				bottom: 0px;
				width: 100%;
				background-color: #D0D0D0;
				color: #FFFFFF;
				line-height: 40px;
				text-align: center;
			}
			.colorblue {
				color: #18b4ed;
			}
			.backgroundcolorblue {
				background-color: #18b4ed;
			}
			#middleId {
				margin-top: 10px;
			}
			.base_back_icon_right {
				height: 20px;
				position: absolute;
				top: 50%;
				right: 15px;
				margin-top: -11px;
			}
		</style>
	</head>
	<body>
		<div class="base_style_color base_title_Immerse" id='BarAppearance' ></div>
		<div class="base_navigation_bar base_style_color base_navigation_item_bar base_title_position" >
			<a class="base_left_item" href="#" onclick="backClick()"> <img class="base_back_icon" src="../../image/icon_jiantou.png" alt=""> </a>
			<span id="newsTitle">互评</span>
			<a class="base_right_item nav-item" id="wancheng"onclick="historyClick()"> <img class="base_back_icon_right" src="../../image/icon_mutualrating__history.png" alt=""> </a>
		</div>
		<div id="main"  hidden="hidden">
			<div class="top-hand-div-style"  >
				<img src="../../image/icon_mutualrating_add.png"  class="top-hand-img-style" id="headImgId" onclick="adddata()"/>
				<span class="base_content_font base_black_grey top-hand-span-style" id="headNameId" onclick="adddata()" > 选择人员</span>
			</div>
			<div class="bottom-btn-div base_title_font" onclick="loaddata()">
				开始评分
			</div>
		</div>
	</body>
	<script type="text/javascript" src="../../script/api.js"></script>
	<script type="text/javascript" src="../../script/jquery.min.js"></script>
	<script type="text/javascript" src="../../script/common.js"></script>
	<script type="text/javascript" src="../../script/MD5.js"></script>
	<script type="text/javascript" src="../../script/timeStampTool.js"></script>
	<script type="text/javascript" src="../../script/requestTool.js"></script>
	<script type="text/javascript" src="../../script/push.js"></script>
	<script type="text/javascript">
		var currentStudents;
		var param = '';
		var stuid = '';
		var pic = '';
		var name = '';
		var type = 0;
		//判断是否是在手机上创建的 1:手机创建，0pc创建
		apiready = function() {
			param = api.pageParam;
			getStatus();
			notice();
			sendBuriedNotifi('0', '老师端互评开启页', '211')
		};
		function backClick() {
			sendBuriedNotifi('1', '老师端互评开启页', '211')
			api.closeWin({
			});
		}
		function sendBuriedNotifi(busionessid, pagetype, pagetypeid) {
			var userinfo = {
				uid : $api.getStorage('cfnetppuid'),
				jid : $api.getStorage('cfnetppjxid'),
				uname : $api.getStorage('cfnetppusername'),
			}
			var data = {
				busionessid : busionessid,
				pagetype : pagetype,
				pagetypeid : pagetypeid,
				sourceurl : api.pageParam.sourceurl,
				sourcetitle : api.pageParam.sourcetitle,
				accesspageurl : window.location.pathname,
				accesspagetitle : document.title,
				userinfo : userinfo
			}
			SendBehaviorTrajectoriesNotifi_Study(data);
		}

		function notice() {
			api.addEventListener({
				name : 'pushMessage_classroomMessage'
			}, function(ret, err) {
				//			alert(JSON.stringify( ret.value));
				if (MUTUAL_START_TYPE == ret.value.type && $api.getStorage('cfnetppjxid') == ret.value.jid && 1 == ret.value.status) {
					if (type != 1) {
						getStatus();
					}
				}
			})
			api.addEventListener({
				name : 'selectStudentNotice'
			}, function(ret, err) {
				var value = ret.value;
				if (value != '') {
					stuid = value.stuid;
					//					alert(stuid != undefined ||stuid != null|| stuid != '');
					if (stuid == undefined || stuid == null || stuid == '') {
						$(".bottom-btn-div").css("background-color", "#D0D0D0");
						$("#headImgId").attr("src", "../../image/icon_mutualrating_add.png");
						$("#headNameId").html("");
						return;
					}
					setAddhtml(value);
				}
			});
		}

		//设置内容
		function setAddhtml(data) {
			pic = data.picurl;
			name = data.name;
			$("#headImgId").attr("src", headImgUrl(pic));
			$("#headNameId").html(name);
			$(".bottom-btn-div").css("background-color", "#18b4ed");
		}

		//历史记录
		function historyClick() {
			api.openWin({useWKWebView:true,
				name : 'MutualRatingHistoryViewWind',
				url : 'MutualRatingHistoryViewWind.html',
				pageParam : {
					pid : api.pageParam.pid,
					cid : api.pageParam.cid,
					sourceurl : api.pageParam.sourceurl,
					sourcetitle : api.pageParam.sourcetitle,
				},
			});
		}

		//添加人员
		function adddata() {
			api.openWin({useWKWebView:true,
				name : 'TeacherMutualRatingView',
				url : 'TeacherMutualRatingView.html',
				pageParam : {
					pid : api.pageParam.pid,
					cid : api.pageParam.cid,
					sourceurl : api.pageParam.sourceurl,
					sourcetitle : api.pageParam.sourcetitle,
				},
			});
		}

		function httpImgUrl(img) {
			var str = img;
			if (str != undefined & str != null & str != '') {
				if (str.substr(0, 7) == "http://") {
					return str
				} else {
					return '../../image/icon_head_ask_class.png';
				}
			} else {
				return '../../image/icon_head_ask_class.png';
			}
		}

		//获取状态
		function getStatus() {
			showProgress();
			var params = {
				jid : $api.getStorage('cfnetppjxid'),
				uid : $api.getStorage('cfnetppuid'),
				tid : "7",
				pid : api.pageParam.pid,
				cid : api.pageParam.cid,
			}
			//alert(JSON.stringify(params));
			cfnetppPOST(url_getActiveStatus, params, true, function(data, status) {
				//							    				alert(JSON.stringify(data));
				api.hideProgress();
				if (status == 'success') {
					if (data.code == 200) {
						var status = data.data.status;
						if (status == 1) {//开始
							$("#main").hide();
							api.hideProgress();
							var y = $('.base_navigation_bar').height() + 22;
							api.openFrame({
								name : 'TeacherMutualRatingViewWind',
								url : 'TeacherMutualRatingViewWind.html',
								rect : {
									x : 0,
									y : y,
									w : 'auto',
									h : 'auto'
								},
								pageParam : {
									stuid : data.data.uid,
									id : data.data.id,
									sourceurl : api.pageParam.sourceurl,
									sourcetitle : api.pageParam.sourcetitle,
								},
							});
						} else {//未开始
							$("#main").show();
						}
					} else {
						$("#main").show();
					}
				} else {
					$("#main").show();
				}
			})
		}

		function loaddata() {
			if (stuid == undefined || stuid == null || stuid == '') {
				return;
			}
			type = 1;
			showProgress();
			var params = {
				jid : $api.getStorage('cfnetppjxid'),
				uid : $api.getStorage('cfnetppuid'),
				tid : "7",
				pid : api.pageParam.pid,
				cid : api.pageParam.cid,
				stuid : stuid
			}
			//			alert("tijj="+JSON.stringify(params));
			cfnetppPOST(url_addActive, params, true, function(data, status) {
				api.hideProgress();
				 SendBusinessOperationsLogNotifi('老师端互评开启', '211', params, params, '', data, '老师端互评开启接口', '211-01')
				//				alert(JSON.stringify(data));
				if (status == 'success') {
					if (data.code == 200) {
						var y = $('.base_navigation_bar').height() + 22;
						api.openFrame({
							name : 'TeacherMutualRatingViewWind',
							url : 'TeacherMutualRatingViewWind.html',
							rect : {
								x : 0,
								y : y,
								w : 'auto',
								h : 'auto'
							},
							pageParam : {
								stuid : stuid,
								id : data.iid,
								sourceurl : api.pageParam.sourceurl,
								sourcetitle : api.pageParam.sourcetitle,
							},
						});
					} else {
							ShowToast(data.message);
						
					}
				}else{
				ShowToast("网络请求失败")
				}
			})
		}
	</script>
</html>